package com.jz.community.modulemine.money.presenter;

import com.jz.community.basecomm.mvp.BaseLifeCyclePresent;
import com.jz.community.basecomm.net.rxandroid.OnLoadListener;
import com.jz.community.modulemine.money.bean.MoneyDetailBean;
import com.jz.community.modulemine.money.bean.MoneyInfoBean;
import com.jz.community.modulemine.money.model.MoneyModel;
import com.jz.community.modulemine.money.model.MoneyModelImp;
import com.jz.community.modulemine.money.ui.MoneyDetailView;

public class MoneyDetailPresenter extends BaseLifeCyclePresent<MoneyDetailView.View> implements MoneyDetailView.Presenter {

    private MoneyDetailView.View view;
    private MoneyModel moneyModel;

    public MoneyDetailPresenter(MoneyDetailView.View view) {
        this.view = view;
        this.moneyModel = new MoneyModelImp(view.getContext());
    }

    @Override
    public void initMoneyData() {
        moneyModel.initMoneyData(new OnLoadListener<MoneyInfoBean>() {
            @Override
            public void onSuccess(MoneyInfoBean moneyInfoBean) {
                view.setMoneyData(moneyInfoBean);
            }

            @Override
            public void onFail(String msg, int code) {
                view.showError(msg);

            }
        });
    }

    @Override
    public void initMoneyDetailList(int page, int size) {
        moneyModel.initMoneyDetailData(page, size, new OnLoadListener<MoneyDetailBean>() {
            @Override
            public void onSuccess(MoneyDetailBean moneyDetailBean) {
                view.setMoneyDetailData(moneyDetailBean);
            }

            @Override
            public void onFail(String msg, int code) {
                view.showError(msg);

            }
        });

    }
}
